import React, { useEffect, useState } from 'react'
import axios from 'axios'

export default function App() {
  const [count, setCount] = useState(0)

  const addCount = () => {
    setCount(count + 1)
  }

  //初始化发送请求
  useEffect(() => {
    axios.get('api1/user')
  }, [])

  //数据发生变化发送请求
  useEffect(() => {
    axios.get('api1/user')
  }, [count])

  
  return (
    <div>
      <h1>count{count}</h1>
      <button onClick={addCount}>累加</button>
    </div>
  )
}
